#ifndef TIMER_H_INCLUDED
#define TIMER_H_INCLUDED

#include "udp.h"

typedef int (*TIMEOUT_FUNC)(MH_UDP *pudp, void *user_data);

struct _CHECK_TIMER
{
    short exec;         /* 是否执行 */
    short acc_time;     /* 累计时间 */
    short set_time;     /* 设置时间 */
    int (*timeout_func)(MH_UDP *pudp, void *user_data);
};

typedef struct _CHECK_TIMER CHECK_TIMER;

void timer_init(CHECK_TIMER *timer);
void timer_start(CHECK_TIMER *timer, short acc_time, short set_time, TIMEOUT_FUNC pfunc);
int timer_exec(MH_UDP *pudp, CHECK_TIMER *timer, void *user_data);
int timer_timeout(CHECK_TIMER *timer);
void timer_stop(CHECK_TIMER *timer);

#endif // TIMER_H_INCLUDED
